package com.session5;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import net.miginfocom.swing.MigLayout;

public class TabDemo extends JFrame implements ChangeListener{
	private JTabbedPane tabPane;
	public TabDemo() {
	}
	public void createForm(){
		this.tabPane =  new JTabbedPane();
		this.tabPane.add("Tab 1", new Tab1());
		this.tabPane.add("Tab 2", new Tab2());
		
		this.getContentPane().add(tabPane);
		this.tabPane.addChangeListener(this);
	}
	public void showForm(){
		this.setTitle("JCombo Demo");
		this.setSize(400,300);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}
	public static void main(String[] args) {
		TabDemo d = new TabDemo();
		d.createForm();
		d.showForm();
	}
	@Override
	public void stateChanged(ChangeEvent e){
		System.out.println(this.tabPane.getSelectedIndex());
		System.out.println(this.tabPane.getSelectedComponent().toString());
	}

}
